import java.util.concurrent.ExecutorService;
import java.util.concurrent.LinkedBlockingQueue;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicInteger;

/**
 * Created by jiangzeyin on 2017/12/18.
 */
public class T {
    private static AtomicInteger atomicInteger = new AtomicInteger(1);
    static int value = 1;

    public static void main(String[] args) {

        ExecutorService executorService = new ThreadPoolExecutor(2, 10, 60, TimeUnit.SECONDS, new LinkedBlockingQueue<>());
        for (int i = 0; i < 10; i++) {
            executorService.execute(() -> {
                for (int i1 = 0; i1 < 10; i1++) {
                    synchronized (T.class) {
                        //System.out.println(atomicInteger.getAndIncrement());
                        System.out.println(value++);
                    }
                }
            });
        }
    }
}
